<template>
	<!-- 訂單管理 -->
  <a-drawer
      :title="title"
      :width="800"
      placement="right"
      :closable="false"
      @close="close"
      :visible="visible"
  >

    <a-spin :spinning="confirmLoading">
      <h2>车主信息</h2>
      <div>购车人:{{model.buyer_name}}</div>
      <div>联系方式:{{model.buyer_phone}}</div>
      <div v-if="model.pin_type==1">购车人证件类型:身份证</div>
      <div v-if="model.pin_type==2">购车人证件类型:护照</div>
      <div v-if="model.pin_type==3">购车人证件类型:士兵证</div>
      <div v-if="model.pin_type==4">购车人证件类型:军官证</div>
      <div>购车人证件号:{{model.pin_number}}</div>
      <div>销售人:{{model.sales_name}}</div>
      <div>所属企业:{{model.dealer_name}}</div>
      <br>
      <h2>车辆信息</h2>
      <div >车架号：{{model.vin}} </div>
      <div >电池组号：{{model.battery_no}} </div>
      <div >品牌：{{model.brand}} </div>
      <div >型号：{{model.model}} </div>
      <div >车型名称：{{model.model_name}} </div>
      <div >车身颜色：{{model.body_color}} </div>
      <div >内饰颜色：{{model.inner_color}} </div>
      <div >发动机号：{{model.engine_no}} </div>
      <div >合格证号：{{model.vehicle_acno}} </div>
      <div >货物进口证明书编号：{{model.import_cert}} </div>
      <div >进口机动车辆随车检验单号：{{model.importmv_iono}} </div>
      <br>
      <h2>交易信息</h2>
      <div >合同编号：{{model.contract_no}} </div>
      <div >发票号：{{model.invoice_number}} </div>
      <div >发票日期：{{model.invoice_time}} </div>
      <div >电池发票号：{{model.battery_invoice_number}} </div>
      <div >电池发票日期：{{model.battery_invoice_time}} </div>
      <div >交车地址：{{model.delivery_addr}} </div>
      <div >交车日期：{{model.delivery_time}} </div>
      <div >成交价：{{model.final_price}} </div>
      <div >所属企业：{{model.QY}} </div>
      <div >所属集团：{{model.JT}} </div>
      <div >销售类型：{{model.selling_type}} </div>
      <div >销售姓名：{{model.sales_name}} </div>
      <div  v-if="model.pin_type==1">证件类型：身份证 </div>
      <div  v-if="model.pin_type==2">证件类型：护照 </div>
      <div  v-if="model.pin_type==3">证件类型：士兵证 </div>
      <div  v-if="model.pin_type==4">证件类型：军官证 </div>
      <div >确认人名：{{model.confirmed_name}} </div>
      <div >企业确认日期：{{model.confirmed_time}} </div>
      <div v-if="model.STATUS==0">交易状态：待完成 </div>
      <div v-if="model.STATUS==1">交易状态：已完成 </div>
      <div v-if="model.STATUS==2">交易状态：已作废 </div>
      <div >备注：{{model.postscript}} </div>



    </a-spin>
    <a-button type="primary" @click="handleCancel">返回</a-button>
  </a-drawer>
</template>

<script>
  import { httpAction } from '@/api/manage'
  import { getTransactionInfo } from '@/api/api'
  import { strReplaceString } from '@/utils/util'
  import pick from 'lodash.pick'
  import moment from "moment"

  export default {
    name: "CxmTransactionModal",
    data () {
      return {
        title:"交易信息",
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },

        confirmLoading: false,
        form: this.$form.createForm(this),
        validatorRules:{
        },
        url: {
          add: "/cxm/cxmTransaction/add",
          edit: "/cxm/cxmTransaction/edit",
        },
      }
    },
    created () {
    },
    methods: {
      close () {
        this.$emit('close');
        this.visible = false;
      },

      handleCancel () {
        this.close()
      },
      showDrawer(record) {
        this.model = Object.assign({}, record);
        let params = {
          id : this.model.id
        }
        console.log(params)
        getTransactionInfo(params).then((res)=>{
          console.log(res.result)
          this.model =  res.result
          this.model.pin_number = strReplaceString(this.model.pin_number,'1')
          this.model.buyer_phone = strReplaceString(this.model.buyer_phone,'2')
        })
        this.visible=true
        console.log(this.model)
      },

    }
  }
</script>

<style lang="less" scoped>
/** Button按钮间距 */
  .ant-btn {
    margin-left: 30px;
    margin-bottom: 30px;
    float: right;
  }
</style>